package com.video.netty.InChannelHandler;

import com.alibaba.fastjson.JSONObject;
import com.video.service.client.IClientService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 终端修改id，golang发送给web
 *
 * {"id": "renameid", "oldid":"3", "newid":"5"}
 */
@BaseChannelHandler.MsgHandler
public class WsRenameidChannelHandler extends BaseChannelHandler {

    @Autowired
    private IClientService clientService;

    @Override
    protected String msgId() {
        return "renameid";
    }

    @Override
    protected void msgHandler(JSONObject json) throws Exception {
        Integer newid = json.getInteger("newid");
        Integer oldid = json.getInteger("oldid");
        clientService.updateUserId(newid, oldid);
    }
}
